<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html">

    <ui:composition template="/WEB-INF/Templates/Template.xhtml">
        <h:outputStylesheet library="css" name="styles.css"/>
        <ui:define name="content">
            <div align="center">
                <h:form>
                    <h:outputText styleClass="overskriftTabell" value="#{tekster.Resultater}"/><br/>
                    <h:selectOneMenu onchange="submit()" required="true" id="velgL" requiredMessage="#{tekster.req_lop}" value="#{rb.resultatene.def}" converter="#{LopConverter}">
                        <f:selectItems value="#{rb.lopene.finnAlleLopSelect()}"/>
                    </h:selectOneMenu>
                    <h:commandButton value="#{tekster.visAlle}" action="#{rb.visAlle()}"/><br/>
                    <h:form>
                        <h:outputText value="#{tekster.SorterEtter}"/>
                        <h:commandButton value="#{tekster.tid}" action="#{rb.sorterEtterTid()}"/>
                        <h:commandButton value="#{tekster.Klasse}" action="#{rb.sorterEtterKlasser()}"/>
                    </h:form>
                    <h:message for="velgL" errorClass="errors"/>

                    <h:dataTable cellspacing="5px" 
                                 value="#{rb.resultatene.hentResultat()}"
                                 var="res" 
                                 border="1"
                                 styleClass="table"
                                 headerClass="tabellerOverskrift"
                                 rowClasses="oddColumn, evenColumn"
                                 footerClass="tabellerOverskrift"
                                 captionClass="overskriftTabell"
                                 width="1000">

                        <h:column>
                            <f:facet name="header">#{tekster.edit}</f:facet>
                            <h:selectBooleanCheckbox value="#{res.editable}" onclick="submit()"/>
                            <f:facet name="footer">#{tekster.Deltakere}#{rb.resultatene.resultat.size()}</f:facet>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.tid}</f:facet>
                            <h:inputText value="#{res.tid}" rendered="#{res.editable}" size="10" converter="#{tid}"/>
                            <h:outputText value="#{res.tid}" rendered="#{not res.editable}"/>
                            <f:facet name="footer">#{rb.ant()}</f:facet>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.Fornavn}</f:facet>
                            <h:outputText value="#{res.delta.fnavn}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.Etternavn}</f:facet>
                            <h:outputText value="#{res.delta.enavn}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.startnr}</f:facet>
                            <h:outputText value="#{res.startNr}"/>
                            <f:facet name="footer"></f:facet>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.Lop}</f:facet>
                            <h:outputText value="#{res.lop.lopnavn}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.Distanse}</f:facet>
                            <h:outputText value="#{res.lop.distanse}">
                                <f:convertNumber pattern="0.0"/>
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{tekster.Klasse}</f:facet>
                            <h:outputText value="#{res.klasse.alder_inndeling}"/>
                            <h:outputText value="#{res.klasse.kjonn}"/>
                        </h:column>
                    </h:dataTable>
                    <ui:debug hotkey="i"/>
                    <h:commandButton value="#{tekster.Lagre}" action="#{rb.save()}"/>
                    <h:commandButton value="#{tekster.Tilbake}" action="/index?faces-redirect=true"/>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>
</html>